package com.senjoeson.abilityservice.action;

import android.accessibilityservice.AccessibilityService;
import android.os.Build;

import androidx.annotation.RequiresApi;

import com.senjoeson.abilityservice.service.AutoAccessibilityService;


/**
 * @USER senjoeson
 * @DATE 2021/1/30 5:19 下午
 * @Desc 系统行为操作具体实现类
 **/
public class SystemActionImpl extends ZeroActionContext implements SystemAction {
    private static final String TAG = "SystemActionImpl";

    public SystemActionImpl(AutoAccessibilityService autoAccessibilityService) {
        super(autoAccessibilityService);
    }

    @Override
    public void powerClick() {
        intervalGlobalClick(AccessibilityService.GLOBAL_ACTION_POWER_DIALOG);
    }

    @Override
    public void backClick() {
        intervalGlobalClick(AccessibilityService.GLOBAL_ACTION_BACK);
    }

    @Override
    public void recentTaskClick() {
        intervalGlobalClick(AccessibilityService.GLOBAL_ACTION_RECENTS);
    }

    @Override
    public void volumeChangeClick(boolean reduce) {
      //  intervalGlobalClick(AccessibilityService.GLOBAL_ACTION_RECENTS);
    }

    @RequiresApi(api = Build.VERSION_CODES.P)
    @Override
    public void screenShotClick() {
        intervalGlobalClick(AccessibilityService.GLOBAL_ACTION_TAKE_SCREENSHOT);
    }


    @RequiresApi(api = Build.VERSION_CODES.P)
    @Override
    public void lockScreen() {
        intervalGlobalClick(AccessibilityService.GLOBAL_ACTION_LOCK_SCREEN);
    }

    @Override
    public void goHomeClick() {
        intervalGlobalClick(AccessibilityService.GLOBAL_ACTION_HOME);
    }

    private void intervalGlobalClick(int action) {
        autoAccessibilityService.performGlobalAction(action);
    }

}
